package com.cs.service.impl;

import com.cs.domain.CsCandidate;
import com.cs.domain.CsTender;
import com.cs.domain.vo.TenderByCandidateVO;
import com.cs.domain.vo.WinningResultsSupplier;
import com.cs.mapper.CSProcurementPlanMapper;
import com.cs.mapper.CsTenderMapper;
import com.cs.service.CSProcurementPlanService;
import com.cs.service.SupplierTenderService;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * @Author：lyj
 * @Package：com.cs.service.impl
 * @Project：RuoYi-Cloud-master
 * @name：SupplierTenderServiceImpl
 * @Date：2024/12/25 10:45
 * @Filename：SupplierTenderServiceImpl
 */
@Service
public class SupplierTenderServiceImpl implements SupplierTenderService {
    @Autowired
    private CsTenderMapper csTenderMapper;
    @Override
    public Map<String, Object> getBidCandidateAndBid() {
        Long userId = SecurityUtils.getLoginUser().getSysUser().getUserId();
        Integer hId = csTenderMapper.UserRelationHid(userId);
        CompletableFuture<List<TenderByCandidateVO>> csTenderCompletableFuture = CompletableFuture.supplyAsync(() -> csTenderMapper.getSupplierBidTender(hId));
        List<CsCandidate> bidWinningCandidateList = csTenderMapper.getBidWinningCandidateByHid(hId,1);//未中标的(未分开的)
        Map<String, Object> map = new HashMap<>();
        map.put("bidWinningCandidateList", bidWinningCandidateList);
        try {
            map.put("csTender", csTenderCompletableFuture.get());
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
        return map;
    }
}
